<?php
	$picture = new Picture();	
	if (isset($picture_id)) {		
		$picture->select($picture_id);
		if (isset($delete) && $delete == 'yes') {
			$hotel = new Hotel();
			$hotel->select($hotel_id);
			$pictures = $hotel->getpictures();
			$pictures = json_decode($pictures, true);
			foreach ($pictures as $index => $id)
				if ($picture->getid() == $id )
					unset($pictures[$index]);
			$pictures = json_encode($pictures);
			$hotel->setpictures($pictures);
			$hotel->update($hotel_id);
			$picture->deleteAllFiles();
			$picture->delete($picture_id);
			admin_load("Hình Đã Được Xoá Thành Công", "?act=pictures_list_for_hotel&hotel_id=$hotel_id");
		}
			
	}
	
	if ($picture || isset($add))
		include "tpl/edit_picture_form.php";
	else
		echo "Hình Ảnh Không Tồn Tại";
?>